/** Description of WTDbAdapter.java 
 *
 * @author panther
 * Jayant Pratim Saikia
 * jay.saikia@gmail.com
 *
 */
package com.panther.awp.android.smoker.database;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;

public class WTDbAdapter extends AbstractDbAdapter {

	public WTDbAdapter(Context context) {
		super(context);
	}
	
	@Override
	public long create(ContentValues values) {
		return mDb.insert(WEEKS_TRACK, null, values);
	}
	
	@Override
	public long update(long _id, ContentValues values) {
		return mDb.update(WEEKS_TRACK, values, WT_PK_ID + "=" + _id, null);
	}

	@Override
	public long delete(long _id) {
		return mDb.delete(WEEKS_TRACK, WT_PK_ID + "=" + _id, null);
	}

	@Override
	public Cursor fetchAll() {
		return mDb.query(WEEKS_TRACK, null, null, null, null, null, null);
	}
	
	@Override
	public Cursor fetch(long _id) {
		return mDb.query(WEEKS_TRACK, null, WT_PK_ID + "=" + _id, null, null, null, null);
	}
	
	@Override
	public Cursor fetchOldest() {
		return mDb.query(true, WEEKS_TRACK, null, null, null, null, null, WT_ENDDATE + " ASC", "1");
	}
	
	@Override
	public Cursor fetchLatest() {
		return mDb.query(true, WEEKS_TRACK, null, null, null, null, null, WT_ENDDATE + " DESC", "1");
	}

}
